<title>旺进财</title>
#@homejs()
#@checkToken2()
#@recharge()
<body  bgcolor="#fafafa" style="margin:0px;">   
	#@homemenu("trade")
	<div align="center" style="width:100%">
		<div style="width:1190px;"> 
			<!--项目信息--> 
			<div style="width:100%;margin-top:10px;height:320px;">
				<div align="left" style="padding:10px 30px 10px 30px;height:300px;width:700px;float:left;background:#FFF">
					<div style="width:700px;font-size:18px;font-weight:400;line-height:50px;"> 
						<span id="name"></span> 
						<span hidden  class="jxyc">仅限一次</span> 	
						<span hidden  class="tyjky">体验金可用</span> 
						<img hidden class="dxhid" style="margin:10px 0 0 10px;" src="#(path)/assets/home/trade/tradeclose.png">
					</div>
					<div style="width:700px;padding-top:15px;height:70px;">
						<div align="left" style="width:200px;float:left">
							<div style="color:#ee3b3f;font-size:30px;"><span id="rate"></span><span style="font-size:18px;" id="plus_rate"></span></div>
							<div style="margin-top:12px;color:#a9a8a6">预期年化利率</div>
						</div>
						<div align="left" style="width:250px;float:left">
							<div style="color:#393939;font-size:30px;"> 
								<span id="day_limit"></span>
								<span style="color:#a8a7a5;font-size:18px;">天</span> 
							</div>
							<div style="margin-top:12px;color:#a9a8a6">期限</div>
						</div>
						<div align="left" style="width:200px;float:left">
							<div align="left" style="width:204px;float:left;margin-top:20px;">
								<div id="least_unit" style="color:#626262;font-size:16px;"></div>
								<div style="margin-top:12px;color:#626262">融资金额：<span id="amount"></span>元</div>
							</div>
						</div>
					</div> 
					<!--进度条-->
					<div style="margin-top:20px;">
						<div style="float:left;width:600px;height:40px;overflow:hidden;">
							<div style="position:relative;float:left;margin-top:9px;height:4px;width:100%;background:#fa3048">
								<div id="jindu" style="position:relative;float:left;height:4px;width:100%;background:#eee"></div>
							</div>
						</div>
						<div id="jindu2" style="height:20px;line-height:20px;float:left;margin-left:20px;font-size:16px;color:#616161"></div>
					</div>
					<div style="width:700px;padding-top:15px;height:70px;">
						<div align="left" style="width:350px;float:left">
							<div align="left" style="width:280px;float:left;">
								<div style="color:#626262;font-size:16px;">起投时间：<span id="start_time"></span></div>
								<div style="margin-top:12px;color:#626262">还款方式：<span id="repay_type"></span></div>
								<div style="margin-top:12px;color:#626262;font-size:16px;">服务协议：
									<span style="cursor:pointer;color:#f15e64" id="fwxy">点击查看</span>
								</div>
							</div>
						</div>
						<div align="left" style="width:280px;float:left">
							<div align="left" style="width:280px;float:left;"> 
								<div style="color:#626262;font-size:16px;">截止时间：<span id="end_time"></span></div>
								<div style="margin-top:12px;color:#626262">起息时间：<span id="invest_start_time"></span></div>
								<div style="margin-top:12px;color:#626262">合同模板：
									<span style="cursor:pointer;color:#f15e64" id="htmb">点击查看</span>
								</div>
							</div>
						</div>
						
					</div> 
				</div>
				<!--右边1 已还款或还款中-->
				<div id="finishrepay" hidden align="left" style="padding:10px 50px 10px 50px;height:300px;width:330px;float:right;background:#FFF">
					<div style="font-size:18px;line-height:40px;margin-top:50px;">剩余可投金额：<span class="shengyu"></span></div>
					<div id="joins" style="font-size:18px;line-height:40px;color:#fa3048"></div>
					<div id="finishday" style="font-size:18px;line-height:40px;"></div>
					<input id="overtypebt" align="center" style="margin-top:10px;color:#fff;height:40px;width:100px;font-size:16px;border-radius:5px;background:#aeaeae" type="button" />
				</div>
				<!--右边1 已满标-->
				<div id="fulling" hidden align="center" style="padding:10px 50px 10px 50px;height:300px;width:330px;float:right;background:#FFF">
					<div style="font-size:18px;line-height:40px;margin-top:50px;">剩余可投金额：<span class="shengyu"></span></div>
					<div id="joins" style="font-size:18px;line-height:40px;color:#fa3048"></div>
					<input id="fullingbt" align="center" style="margin-top:10px;color:#fff;height:40px;width:100px;font-size:16px;border-radius:5px;background:#f15e64" type="button" />
				</div>
				<!--右边2 正常投资中-->
				<div id="trading" hidden align="left" style="padding:10px 50px 10px 50px;height:300px;width:330px;float:right;background:#FFF">
					<div style="font-size:18px;line-height:40px;">剩余可投金额：<span class="shengyu"></span></div>
					<div style="font-size:18px;line-height:40px;">账户余额：<span class="availableAmount"></span></div> 
					<div  id="buyNumber">
						<div style="font-size:16px;line-height:40px;color:#f15e64">购买份数 </div>
						<div style="font-size:18px;line-height:40px;margin-top:10px;">
							<input class="buyNum" style="padding-left:15px;height:40px;width:120px;font-size:16px;border:1px solid #bebebe;border-radius:5px;"  />
							<input id="allable" value="一键投资" align="center" style="cursor:pointer;color:#bebebe;height:40px;width:80px;font-size:14px;border:1px solid #bebebe;border-radius:5px;background:#FFF" type="button" />
						</div>
						<div style="margin-top:5px;"><span style="color:#000;margin-left:0px;font-size:14px;"><span style="color:#f15e64" id="allmoney">0元</span></span></div>
						<div style="font-size:16px;line-height:40px;margin-top:0px;">预期收益：<span id="forecast" style="color:#28a1f4"></span></div>
						<div style="font-size:18px;line-height:40px;margin-top:px;">
							<input id="tradetrue" value="立即投资" align="center" style="cursor:pointer;color:#fff;height:40px;width:100px;font-size:16px;border-radius:5px;background:#f15e64" type="button" />
							<input class="rechargebt" value="充值" align="center" style="cursor:pointer;color:#fff;height:40px;width:100px;font-size:16px;border-radius:5px;background:#f15e64;margin-left:50px;" type="button" />
						</div>
					</div>
				</div>
				<!--右边2 体验金投资中-->
				<div id="experitrading" align="center" style="padding:10px 50px 10px 50px;height:300px;width:330px;float:right;background:#FFF">
					<div style="font-size:18px;line-height:40px;margin-top:80px;">剩余可投金额：<span class="shengyu"></span></div>
					
					<div >
						<div style="font-size:18px;line-height:40px;margin-top:30px;">
							<input id="expiretradetrue" value="立即投资" align="center" style="cursor:pointer;color:#fff;height:40px;width:100px;font-size:16px;border-radius:5px;background:#f15e64" type="button" />
						</div>
					</div>
				</div>
				<!--右边3 未开始-->
				<div id="waiting" hidden align="left" style="padding:10px 50px 10px 50px;height:300px;width:330px;float:right;background:#FFF">
					<div style="font-size:18px;line-height:40px;margin-top:50px;">剩余可投金额：<span class="shengyu"></span></div>
					<div style="font-size:18px;line-height:40px;">账户余额：<span class="availableAmount"></span></div>
					<div style="font-size:18px;line-height:40px;">倒计时：<span class="daojishi"></span></div>
					<input value="未开始" align="center" style="margin-top:10px;color:#fff;height:40px;width:100px;font-size:16px;border-radius:5px;background:#aeaeae" type="button" />
				</div> 
			</div> 
			 
			<!--项目证件合同-->
			<div align="center" style="width:1190px;height:700px;;margin-top:10px;background:#FFF;">  
				<div style="width:1190;border-bottom:1px solid #ebebeb;height:60px;line-height:60px;"> 
					<div session="tradeactive" class="tradeinfo1 tradeinfo">活动信息</div>
					<div id="tradepic" session="tradepic" class="tradeinfo1">证件信息</div> 
					<div session="trades" class="tradeinfo1">投资记录</div>  
				</div>    
				<div id="iteminfo" align="left" style="background:#FFF;width:1150;height:600px;line-height:40px;overflow:auto;overflow-x:hidden;">  
					
				</div> 
			</div>
		</div>
	</div>
	<!--@paginate(page.pageNumber, page.totalPage, "/blog/")-->
	<!--foot-->
	#@homefoot1()
	#@homefoot2()
	<div id="mengban" hidden style="background-color:rgba(0,0,0,0.4);position:fixed;top:0;width:100%;height:100%;z-index:550"> 
		<div align="center" style="width:100%;">
			<div style="width:1100px;font-size:14px;">
				<div id="passinput" hidden style="width:500px;height:200px;position:relative;top:200px;background:#FFF">
					<div id="tan_title" style="font-size:18px;height:40px;line-height:40px;background:#fafafa">
						请输入投资密码
						<img class="closethis2" style="cursor:pointer;height:30px;float:right;margin-top:-10px;margin-right:-10px;" src="#(path)/assets/home/account/account_img18.png">
					</div>    
					<div>
						<input type="password" id="tradepass" style="margin-top:30px;padding-left:15px;height:35px;width:300px;font-size:16px;border:1px solid #bebebe;border-radius:5px;"  />
						<br>
						<input id="tradepasstrue" value="确 定" align="center" style="cursor:pointer;margin-top:30px;color:#fff;height:35px;width:100px;font-size:16px;border-radius:5px;background:#f15e64" type="button" />
					</div>
				</div>
				
				<div  id="buytradeinfo" hidden style="width:500px;height:auto;position:relative;top:200px;background:#FFF">
					<div style="font-size:18px;height:40px;line-height:40px;background:#fafafa">
						投资确认
						<img class="closethis" style="cursor:pointer;height:30px;float:right;margin-top:-10px;margin-right:-10px;" src="#(path)/assets/home/account/account_img18.png">
					</div>
					<div style="margin-left:100px;" align="left">
						<div style="font-size:18px;line-height:40px;margin-top:10px;">投资标的：<span id="true_bid"></span></div>
						<div style="font-size:18px;line-height:40px;margin-top:10px;">投资份数：<span id="true_Num"></span>份</div>
						<div style="font-size:18px;line-height:40px;margin-top:10px;">投资金额：<span id="true_money"></span></div>
						<div style="font-size:18px;line-height:40px;margin-top:10px;">预期收益：<span id="true_forecast"></span></div>
						<div style="font-size:18px;line-height:40px;margin-top:10px;">
							优 惠 券：
							<span getcoupontype=" " getcouponid=" " style="border-radius:2px;border:1px solid #eee;color:#fa4357;font-size:14px;padding:2px 5px 2px" class="yhq_num"></span>
							<img class="investProm_jia" style="vertical-align:middle;height:16px;"src="#(assets)/images/mobile/personal_jiantou2.png">
							<div hidden class="investProm_jialist" style="width:300px;max-height:200px;overflow:auto;overflow-x:hidden;">
								<div class="alllist" align="center" style=""></div>
								<div class="showlists"></div>	
							</div> 
						</div>
					</div>
					<input id="bidtruebt" value="确 定" align="center" style="cursor:pointer;margin:20px 0 20px 0;color:#fff;height:35px;width:100px;font-size:16px;border-radius:5px;background:#f15e64" type="button" />
				</div>
				<div  id="buytradeinfo2" hidden style="width:500px;height:auto;position:relative;top:200px;background:#FFF">
					<div style="font-size:18px;height:40px;line-height:40px;background:#fafafa">
						投资确认
						<img class="closethis" style="cursor:pointer;height:30px;float:right;margin-top:-10px;margin-right:-10px;" src="#(path)/assets/home/account/account_img18.png">
					</div>
					<div style="margin-left:100px;" align="left">
						<div style="font-size:18px;line-height:40px;margin-top:10px;">
							体 验 金：
							<span getcoupontype=" " getcouponid=" " style="border-radius:2px;border:1px solid #eee;color:#fa4357;font-size:14px;padding:2px 5px 2px" class="yhq_num"></span>
							<img class="investProm_jia" style="vertical-align:middle;height:16px;"src="#(assets)/images/mobile/personal_jiantou2.png">
							<div hidden class="investProm_jialist" style="width:300px;max-height:200px;overflow:auto;overflow-x:hidden;">
								<div class="alllist" align="center" style=""></div>
							</div> 
						</div>
					</div>
					<input id="expiretruebt" value="确 定" align="center" style="cursor:pointer;margin:20px 0 20px 0;color:#fff;height:35px;width:100px;font-size:16px;border-radius:5px;background:#f15e64" type="button" />
				</div>
			</div> 
		</div> 
	</div> 
	
<script id="demo" type="text/x-jquery-tmpl">
	<div align="center" pass="${coupon_id}" limitamount="${limit_amount}" class="pass" pass2="${amount}" pass3="${types}" pass4="${yhq_type}" style="clear:both;margin-top:10px;background:#FFF;width:100%;">
		<div style="width:96%;height:70px;margin-top:10px;border:1px solid #b8b8b8;border-radius:10px">
		<div style="border-bottom:1px dashed #000;height:34px;">
			<div style="float:left;margin-left:10px;line-height:34px;font-size:14px;">${amount}</div>
			<div style="float:left;font-size:12px;margin-left:10px;line-height:34px;">失效时间：${valid_end_time}</div>
			<div style="float:right;margin-right:10px;"><img style="width:20px;" src="${url1}"></div>
		</div>
		<!--<img style="width:40px;float:right;margin-top:-15px" src="#(assets)/images/mobile/reward_shixiao.png"> -->
		<div>
		<!--<div align="left" style="font-size:12px;margin-left:10px;line-height:17px;">${allow_bid}</div>-->
			<div align="left" style="font-size:12px;margin-left:10px;line-height:17px;">${limit_amount}</div>
		</div>
	</div>   
</script>   
<script>	
$(document).ready(function(){  
	var id = GetRequest()["id"];
	var url ="#(path)/bid/toTrade?token=#(session.token??)&id="+id; 
	var oneunit;
	var is_real_name_verify;
	var is_bind_bank_card;
	var is_set_pay_password;
	var is_withhold_authority;
	var allableNum;
	var availableAmount;
	$.getJSON(url, function(data) { 
		console.log(data);
		var bidinfo3 = data.data.item;
		var limitamount;
		var userinfo = data.data.user;
		is_real_name_verify = userinfo.is_real_name_verify;
		is_bind_bank_card = userinfo.is_bind_bank_card;
		is_set_pay_password = userinfo.is_set_pay_password;
		is_withhold_authority = userinfo.is_withhold_authority;
		availableAmount = Number(userinfo.availableAmount);
		$(".availableAmount").html(availableAmount+"元");
		if(is_real_name_verify==0){
			layer.msg("您还未实名，实名后才能进行投资！",{icon:2,time:2000},function(){
				window.location.href="/account-account?type=setaccount"; 
			});
		}else if(is_bind_bank_card==0){
			layer.msg("您还未绑卡，绑卡后才能进行投资！",{icon:2,time:2000},function(){
				window.location.href="/account-account?type=setaccount"; 
			});
		}else if(is_set_pay_password==0){
			layer.msg("您还未设置支付密码，设置支付密码后才进行能投资！",{icon:2,time:2000},function(){
				window.location.href="/account-account?type=setaccount"; 
			});
		}else if(is_withhold_authority==0){
			layer.msg("您还未设置委托扣款，设置委托扣款后才进行能投资！",{icon:2,time:2000},function(){
				window.location.href="/account-account?type=setaccount"; 
			});
		}
		//点击立即投资
		$(".yhq_num").html("您无可用优惠券");
		$("#tradetrue").click(function(){
			$(".alllist").empty();
			var re =  /^\+?[1-9][0-9]*$/;
			var buyNum = $(".buyNum").val();
			if(!re.test(Number(buyNum))){ 
				layer.msg("请输入数字！",{icon:2,time:2000});
			}else if($.isBlank(buyNum)){ 
				layer.msg("投资份数不能为空！",{icon:2,time:2000});
			}else{
				if(buyNum==0){
					layer.msg("投资份数不能为0！",{icon:2,time:1000});
				}else{
					//筛选优惠券
					var trueamount = buyNum * bidinfo3.unit_amount;
					console.log(trueamount);
					$.each(data.data.coupon, function(i, item){ 
						console.log(item);
						if(item.type=="jxq"){
							var url1 = "#(assets)/images/mobile/reward_1.png";
							var amount = item.amount + "%";
							var types = "加息券";
						}else if(item.type=="tyj"){
							var url1 = "#(assets)/images/mobile/reward_3.png";
							var amount = item.amount + "元";
							var types = "体验金";
						}else if(item.type=="tzhb"){
							var url1 = "#(assets)/images/mobile/reward_2.png"; 
							var amount = item.amount + "元";
							var types = "返现券"; 
						} 
						var invests = {coupon_id:item.id,yhq_type:item.type,types:types,url1:url1,amount:amount,valid_end_time:item.valid_end_time,allow_bid:item.allow_bid,limit_amount:item.limit_amount};
						var limitam = item.limit_amount;
						limitam = Number(limitam.substr(1,limitam.length-4));
						if(trueamount > limitam){
							$(".yhq_num").html("您有可用优惠券，请选择");
							console.log(1);
							$("#demo").tmpl(invests).appendTo('.alllist'); 
						}
					});
					
					$("#true_Num").html(buyNum);
					$("#true_money").html(buyNum * bidinfo3.unit_amount+"元"); 
					var true_forecast = (buyNum * bidinfo3.unit_amount * (Number(bidinfo3.rate)+Number(bidinfo3.plus_rate)) * Number(bidinfo3.day_limit) / 36000).toFixed(2);
					$("#true_forecast").html(true_forecast + "元");
					$("#mengban").show(); 
					$("#buytradeinfo").show();  
					$("#true_bid").html(bidinfo3.name);
				}
			}
		});
		setInterval( function getbuynum(){  
			var getbuynum = $(".buyNum").val();
			if(getbuynum==" "){
				getbuynum = 0;
			}else{
				var shouyi = (Number(getbuynum) * Number(bidinfo3.unit_amount) * (Number(bidinfo3.rate)+Number(bidinfo3.plus_rate)) * Number(bidinfo3.day_limit) / 36000).toFixed(2);
			}  
			var allmoney = getbuynum * oneunit;
			$("#allmoney").html(allmoney+"元");
			$("#forecast").html(shouyi+"元");
		},500);
		//判断有无优惠券
		/*if(data.data.coupon.length ==0 ){
			$(".yhq_num").html("您无可用优惠券");
		}else{
			$(".yhq_num").html("您有可用优惠券，请选择");
			$.each(data.data.coupon, function(i, item){ 
				console.log(item);
				if(item.type=="jxq"){
					var url1 = "#(assets)/images/mobile/reward_1.png";
					var amount = item.amount + "%";
					var types = "加息券";
				}else if(item.type=="tyj"){
					var url1 = "#(assets)/images/mobile/reward_3.png";
					var amount = item.amount + "元";
					var types = "体验金";
				}else if(item.type=="tzhb"){
					var url1 = "#(assets)/images/mobile/reward_2.png"; 
					var amount = item.amount + "元";
					var types = "返现券"; 
				} 
				var invests = {coupon_id:item.id,yhq_type:item.type,types:types,url1:url1,amount:amount,valid_end_time:item.valid_end_time,allow_bid:item.allow_bid,limit_amount:item.limit_amount};
				$("#demo").tmpl(invests).appendTo('.alllist'); 
			});
		}*/
		//展示优惠券
		$(".yhq_num").click(function(){
			$(".investProm_jialist").toggle();
			var node=$('.investProm_jialist');
			if(node.is(':hidden')){　　//如果node是隐藏的则显示node元素，否则隐藏
			　　$(".investProm_jia").attr("src","#(assets)/images/mobile/personal_jiantou2.png");
			}else{
			　　$(".investProm_jia").attr("src","#(assets)/images/mobile/personal_jiantou3.png");
			}			
		});	
		//选择优惠券
		var cheseamount;
		$(".pass").click(function(){
			var that = $(this);
			couponid = that.attr("pass");
			$(".yhq_num").attr("getcouponid",couponid)
			$(".yhq_num").attr("getcoupontype",that.attr("pass4"))
			yhq_type2 = that.attr("pass4");
			cheseamount = that.attr("pass2");  
			var aaa = that.attr("pass2") + "(" + that.attr("pass3") + ")";
			$(".investProm_jialist").hide();
			$(".yhq_num").html(aaa);  
			limitamount = that.attr("limitamount");  
		});
		//最后一步确认提交信息
		$("#bidtruebt").click(function(){
			var getcptype = $(".yhq_num").attr("getcoupontype");
			var getcpid = $(".yhq_num").attr("getcouponid");
			var unit = $("#true_Num").html();
			layer.confirm('是否确认提交？', {
			  btn: ['确定','取消'] //按钮 
			}, function(){
				$("#mengban").hide();
				$(".buyNum").attr("disabled",true);
				$("#tradetrue").attr("disabled",true); 
				$(".rechargebt").attr("disabled",true); 
				$("#allable").attr("disabled",true); 
				layer.msg('投资中',function(){
					if(!$.isBlank(getcpid)){ 
						var url2="#(path)/trade?token=#(session.token??)&bid="+id+"&unit="+unit+"&ip=127.0.0.1"+"&"+getcptype+"="+getcpid;
					}else{
						var url2="#(path)/trade?token=#(session.token??)&bid="+id+"&unit="+unit+"&ip=127.0.0.1";
					}
					$.getJSON(url2, function(datainfo) {
						if(datainfo.code=='success'){
							layer.msg("投资成功！",{icon:1,time:2000},function(){
								window.location.href="#(path)/account-account?type=userinvest";
							});
						}else{
							$(".buyNum").attr("disabled",false);
							$("#tradetrue").attr("disabled",false); 
							$(".rechargebt").attr("disabled",false); 
							$("#allable").attr("disabled",false);
							layer.msg(datainfo.msg,{icon:2,time:1000}); 
						}
					});
				});
			}, function(){
			  $("#mengban").hide();
			});
		});
		$("#expiretruebt").click(function(){
			var getcptype = $(".yhq_num").attr("getcoupontype");
			var getcpid = $(".yhq_num").attr("getcouponid");
			if($.isBlank(getcptype)||$.isBlank(getcpid)){
				layer.msg("未使用体验金！",{icon:2,time:1000}); 
			}else{
				var i = layer.confirm('是否确认提交？', { 
				  btn: ['确定','取消'] //按钮
				}, function(){
					$("#expiretradetrue").attr("disabled",true);
					layer.msg('投资中',function(){
						var expireamount = Number(cheseamount.substring(0,cheseamount.Length-3)); 
						var url2="#(path)/trade?token=#(session.token??)&bid="+id+"&unit="+expireamount+"&ip=127.0.0.1"+"&"+getcptype+"="+getcpid;
						$.getJSON(url2, function(datainfo) {
							if(datainfo.code=='success'){
								layer.msg("投资成功！",{icon:1,time:2000},function(){
									window.location.href="#(path)/account-account?type=userinvest";
								}); 
							}else{
								$("#expiretradetrue").attr("disabled",false);
								layer.msg(datainfo.msg,{icon:2,time:2000}); 
							}
						});
					});
				}, function(){
				  $("#mengban").hide();
				});
			}
		});
	});
	
	$.getJSON("#(path)/bid/info?token=#(session.token??)&id="+id, function(bidinfo) { 
		var	tradeable = true;	
		var detail = bidinfo.data.detail;
		var trades = bidinfo.data.trades;
		var bidinfo2 = bidinfo.data.item;
		var bidstart = bidinfo2.start_time;
		var now = bidinfo.data.now;
		oneunit = bidinfo2.unit_amount;
		//定向加密验证
		if(bidinfo2.is_direct==1){
			$("#mengban").show(); 
			$("#passinput").show();
			$("#tradepasstrue").click(function(){
				var password1 = $("#tradepass").val();
				if(password1==bidinfo2.password){
					layer.msg("密码验证成功！",{icon:1,time:1000},function(){
						$("#mengban").hide();
						$("#passinput").hide();
					});  
				}else{
					layer.msg("密码错误！",{icon:2,time:1000});
				}  
			});
		}
		$(".closethis2").click(function(){
			layer.msg("定向标的，定向密码验证成功才可投资！",{icon:2,time:1000},function(){
				window.location.href="#(path)/trade-tradelist";  
			});
		});
		$("#fwxy").click(function(){
			window.open("#(path)/trade-tradejujian");  
		});
		$("#name").html(bidinfo2.name);
		$("#amount").html(bidinfo2.amount);
		$("#rate").html(bidinfo2.rate+"%");
		$("#start_time").html(bidinfo2.start_time);
		$("#end_time").html(bidinfo2.end_time);
		if(bidinfo2.repay_type=="all"){
			$("#repay_type").html("到期还本付息");
		}else if(bidinfo2.repay_type=="schedule"){
			$("#repay_type").html("按月付息到期还本");
		}else if(bidinfo2.repay_type=="interest"){
			$("#repay_type").html("等额本息");
		}else if(bidinfo2.repay_type=="capital"){
			$("#repay_type").html("等额本金"); 
		}
		if($.isBlank(bidinfo2.invest_start_time)){
			$("#invest_start_time").html("项目成立日");
		}else{
			$("#invest_start_time").html(bidinfo2.invest_start_time);
		}
		if(bidinfo2.plus_rate=="0.0"){
			$("#plus_rate").html("");
		}else{
			$("#plus_rate").html("+"+bidinfo2.plus_rate+"%");
		}
		$("#day_limit").html(bidinfo2.day_limit);
		if(bidinfo2.is_direct=="1"){ 
			$(".dxhid").show();
		}
		//标的类型判断
		if(bidinfo2.type=="experi"){ 
			$("#htmb").click(function(){
				window.open("#(path)/trade-tradehtmb?type=excontract");  
			});
			$("#trading").remove();
			$(".tyjky").show();
			$("#tradepic").hide(); 
			$("#least_unit").html("起投金额"+bidinfo2.least_unit+"元");
		}else{
			$("#experitrading").remove();
			$("#htmb").click(function(){
				window.open("#(path)/trade-tradehtmb?type=contract");  
			});
			$("#least_unit").html("起投份数"+bidinfo2.least_unit+"份");
			if(bidinfo2.type == "first"){ 
				$(".jxyc").show();
			}
		}  
		var jindu = (Number(bidinfo2.avunit) * Number(bidinfo2.unit_amount)*100/ Number(bidinfo2.amount)).toFixed(2);
		$("#jindu2").html(jindu+"%");	
		$("#jindu").animate({left:jindu+'%'},1000);
		$("#iteminfo").load("#(path)/trade-tradeactive");
		$(".tradeinfo1").click(function(){
			$(".tradeinfo1").removeClass("tradeinfo"); 
			$(this).addClass("tradeinfo"); 
			var loadinfo = $(this).attr("session");
			$("#iteminfo").load("#(path)/trade-"+loadinfo+"?id="+id);
		});
		
		//标的状态
		//已还款或待还款
		if(bidinfo2.status=="finish"||bidinfo2.status=="repaying"){
			$("#finishrepay").show();
			$("#waiting").remove();
			$("#trading").remove();
			$("#fulling").remove();
			$("#experitrading").remove();
			$(".shengyu").html(0);
			$("#joins").html("加入人数："+trades.length+"人");
			$("#finishday").html("合同成立日："+bidinfo2.invest_start_time);
			if(bidinfo2.status=="finish"){
				$("#overtypebt").val("已还款");
			}else if(bidinfo2.status=="repaying"){
				$("#overtypebt").val("还款中");
			}
		}else if(bidinfo2.status=="full"){
			$("#fulling").show();
			$("#finishrepay").remove();
			$("#waiting").remove();
			$("#trading").remove();
			$("#experitrading").remove();
			$(".shengyu").html(0);
			$("#joins").html("加入人数："+trades.length+"人");
			$("#overtypebt").val("已满标");
		}else if(bidinfo2.status=="trading"){
		//投资中
			$("#finishrepay").remove();
			$("#waiting").remove(); 
			$("#fulling").remove();
			if(bidinfo2.type=="experi"){
				$("#experitrading").show();
			}else{
				$("#trading").show();
			}
			var bigable="";
			var shengyu = (Number(bidinfo2.amount)/ Number(bidinfo2.unit_amount)) - Number(bidinfo2.avunit);
			$(".shengyu").html(shengyu+"份");
			//console.log(bigable);
			$("#allable").click(function(){
				 allableNum = Math.floor(Number(availableAmount)/ Number(bidinfo2.unit_amount));
				if(allableNum > shengyu){
					bigable = shengyu;
				}else{
					bigable = allableNum;
				}
				console.log(allableNum,shengyu);
				if(allableNum > shengyu){
					$(".buyNum").val(Number(shengyu));
				}else{
					$(".buyNum").val(Number(allableNum));
				}
			});
			$("#expiretradetrue").click(function(){
				$("#mengban").show();  
				$("#buytradeinfo2").show();
			});
		}else if(bidinfo2.status=="waiting"){ 
			$("#waiting").show();
			$("#finishrepay").remove(); 
			$("#trading").hide();
			$("#fulling").remove();
			var now = bidinfo.data.now;
			var bidstart = bidinfo2.start_time;
			var shengyu = (Number(bidinfo2.amount)/ Number(bidinfo2.unit_amount)) - Number(bidinfo2.avunit)+"份";
			$(".shengyu").html(shengyu);
			$.getJSON("#(path)/user/info?token=#(session.token??)", function(data) {
				$(".availableAmount").html(data.data.info.availableAmount+"元");
				$("#allable").click(function(){
					var allableNum = Math.floor(Number(availableAmount)/ Number(bidinfo2.unit_amount));
					if(allableNum > shengyu){
						$(".buyNum").val(shengyu);
					}else{
						$(".buyNum").val(allableNum);
					}
				});
			});
			var timestamp1 = Date.parse(new Date(now))/1000;
			var timestamp2 = Date.parse(new Date(bidstart))/1000; 
			setInterval(function countTime() {
				timestamp1++;
				if(timestamp1<timestamp2){ 
					var timestamp = timestamp2 - timestamp1;
					var day1=Math.floor(timestamp/(60*60*24)); 
					var hour=Math.floor((timestamp-day1*24*60*60)/3600); 
					var minute=Math.floor((timestamp-day1*24*60*60-hour*3600)/60); 
					var second=Math.floor(timestamp-day1*24*60*60-hour*3600-minute*60); 
					$(".daojishi").html(day1+"天"+hour+"小时"+minute+"分"+second+"秒")
				}else{
					if(bidinfo2.type=="experi"){
						$("#experitrading").show();
					}else{
						$("#trading").show();
					}
					$("#waiting").hide();
				}
			},1000); 
		}
	});
	$(".closethis").click(function(){
		$("#mengban").hide();
	});
	function GetRequest() {   
	   var url = location.search; //获取url中"?"符后的字串  
	   var theRequest = new Object();  
	   if (url.indexOf("?") != -1) {  
		  var str = url.substr(1);  
		  strs = str.split("&");  
		  for(var i = 0; i < strs.length; i ++) {  
			 theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);  
		  }  
	   }  
	   return theRequest;  
	}  
});
</script>
</body>